<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class User extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // GetOtherUserInfo 验证场景定义
    public function sceneGetOtherUserInfo()
    {
        return $this->append('user_id', 'require');
    }

    // GetAddressList 验证场景定义
    public function sceneGetAddressList()
    {
        return $this->append('tenant_id', 'require');
    }

    // SelectUser 验证场景定义
    public function sceneSelectUser()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // AddUserWithMedia 验证场景定义
    public function sceneAddUserWithMedia()
    {
        return $this->append('data', 'require')
            ->append('data.phone', 'require')
            ->append('data.password', 'require')
            ->append('media', 'array');
    }

    // ModifyUserWithMedia 验证场景定义
    public function sceneModifyUserWithMedia()
    {
        return $this->append('data', 'require|array')
            ->append('filter', 'require|array')
            ->append('media', 'array');
    }

    // ModifyCurrentUserPassword 验证场景定义
    public function sceneModifyCurrentUserPassword()
    {
        return $this->append('old_password', 'require')
            ->append('new_password', 'require');
    }

    // DeleteUser 验证场景定义
    public function sceneDeleteUser()
    {
        return $this->append('param.filter', 'require|array');
    }

    // SwitchActiveUser 验证场景定义
    public function sceneSwitchActiveUser()
    {
        return $this->append('param.filter', 'require|array');
    }

    // GetOtherUsersInfo 验证场景定义
    public function sceneGetOtherUsersInfo()
    {
        return $this
            ->append("param", "require|array")
            ->append("param.filter", "require|array");
    }

    // Register 验证场景定义
    public function sceneRegister()
    {
        return $this->append('data', 'require')
            ->append('data.phone', 'require')
            ->append('data.password', 'require')
            ->append('sms_code', 'require')
            ->append('media', 'array');
    }

    // GetTenantBalance 验证场景定义
    public function sceneGetTenantBalance()
    {
        return $this->append('tenant_id', 'require');
    }


    // OrderDeduction 验证场景定义
    public function sceneOrderDeduction()
    {
        return $this->append('id', 'require')
            ->append('tenant_id', 'require')
            ->append('money', 'require')
            ->append('belong_system', 'require');
    }

    // OrderIncrease 验证场景定义
    public function sceneOrderIncrease()
    {
        return $this->append('id', 'require')
            ->append('tenant_id', 'require')
            ->append('money', 'require|gt:0')
            ->append('belong_system', 'require');
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append("param.filter", "array");
    }

    // SelectSystemUser 验证场景定义
    public function sceneSelectSystemUser()
    {
        return $this
            ->append("param.filter", "array")
            ->append("param.page", "array");
    }

    // SelectNormalUser 验证场景定义
    public function sceneSelectNormalUser()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    //获取当前用户部门
    public function sceneGetCurrentDepartment()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.filter.user_id', 'require');
    }

    //常用联系人
    public function frequentContacts()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.filter.user_id', 'require');
    }

    //注销用户后离开聊天会话
    public function sceneSwitchActiveUserChat()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'require')
            ->append('param.filter.is_active', 'require');
    }

    // 通过手机号获取用户id
    public function sceneGetUserId()
    {
        return $this->append('data', 'require')
            ->append('data.mobile_list', 'require');
    }

    // SearchTenantUser 验证场景定义
    public function sceneSearchTenantUser()
    {
        return $this->append('param.filter.tenant_id', 'integer')
            ->append('param.filter.name_or_phone', 'require');
    }
}
